<include file="public/head" />
</head>
<body>
<div class="am-modal am-modal-alert" tabindex="-1" id="fq_alert">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_alert_title"></div>
    <div class="am-modal-bd" id="fq_alert_info">
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="fq_confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_confirm_title"></div>
    <div class="am-modal-bd" id="fq_confirm_info"></div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-confirm="">确定</span>
    </div>
  </div>
</div>
<link rel="stylesheet" href="__STATIC__/itaoke/mobile/css/integralmall.css">
<div class="am-bd">
    <header style="position:relative;z-index:999;background:#F54D23;">
    <a href="javascript:void(0);" onclick="back();" style="position:absolute;top:2px;color:#fff;width:45px;height:100%;padding-left:10px;font-size:25px;" class="am-inline-block am-text-middle am-icon-angle-left"><!-- <img src="/Public/assets/mobile/images/left.png" />--></a><div class="am-per-center am-text-center am-padding-vertical-sm" style="color:#fff;font-size:16px;">积分商城</div>
</header>
<script>

    function back(){
       var last_page_url = (document.referrer);
       if(last_page_url){
          	window.history.back();
		}else{
			window.location.href ='{:U('User/index')}';
		}
    }

</script>
    <div class="am-message am-vertical-align am-padding-horizontal-xs am-margin-bottom-xs am-text-sm fq-background-white">
        <img src="{:avatar($info['id'], 200)}" class="am-round am-vertical-align-middle am-portrait am-text-sm">
        <span class="am-vertical-align-middle am-margin-left-sm am-text-sm" style="margin-top: .2rem">我的积分：</span>
        <span class="am-vertical-align-middle integral-fraction myscore am-text-sm" style="margin-top: .2rem">{$score_total}</span>
        <span class="am-fr am-vertical-align-middle am-exchange am-margin-top-xs fq-background-white am-text-sm" style="padding: 3px 5px 3px 5px;">
            <a href="{:U('User/gift')}">我的兑换</a>
        </span>
    </div>
    <nav>
        <div class="am-tabs ">
            <ul class="am-tabs-nav am-nav am-padding-horizontal-xs am-nav-tabs am-padding-horizontal-xs am-margin-bottom-xs fq-background-white" style="height: 36px; ">
                <li class="<if condition="$cid eq ''">am-active</if>"><a href="{:U('Gift/index')}" style="padding-left: 10px; padding-right: 10px">全部</a></li>
                <volist name="cate_lists" id="vo">
                <li class="<if condition="$vo.id eq $cid">am-active</if>"><a href="{:U('Gift/index',array('cid'=>$vo['id']))}" style="padding-left: 10px; padding-right: 10px">{$vo.name}</a></li>
                </volist>
                <select data-am-selected="{btnWidth: '25%', btnSize: 'sm'}" class="am-fr sort" data-selected="" data-type="0" style="display: none;">
                    <option value="new" data-am-selected="{btnWidth:'100%'}" style="display: none;">最新排序</option>
                    <div class="am-selected am-dropdown " id="am-selected-w8u4u" data-am-dropdown="" style="width: 100%;">  <button type="button" class="am-selected-btn am-btn am-dropdown-toggle am-btn-default">    <span class="am-selected-status am-fl"></span>    <i class="am-selected-icon am-icon-caret-down"></i>  </button>  <div class="am-selected-content am-dropdown-content">    <h2 class="am-selected-header"><span class="am-icon-chevron-left">返回</span></h2>       <ul class="am-selected-list"></ul>    <div class="am-selected-hint"></div>  </div></div>
                    <option value="asc">积分升序</option>
                    <option value="desc">积分降序</option>
                    <option value="hot">人气</option>
                </select>
          <!--      <div class="am-selected am-dropdown " id="am-selected-e43ao" data-am-dropdown="" style="width: 25%;">  
                <button type="button" class="am-selected-btn am-btn am-dropdown-toggle am-btn-sm am-btn-default">    
                <span class="am-selected-status am-fl">最新排序</span>    
                <i class="am-selected-icon am-icon-caret-down"></i>  
                </button>  
                <div class="am-selected-content am-dropdown-content">    
                <h2 class="am-selected-header"><span class="am-icon-chevron-left">返回</span></h2>       
                <ul class="am-selected-list">                     
	                <li class="am-checked" data-index="0" data-group="0" data-value="0">         
	                <span class="am-selected-text">最新排序</span>         
	                <i class="am-icon-check"></i></li>                                 
	                <li class="" data-index="1" data-group="0" data-value="1">         
	                <span class="am-selected-text">积分升序</span>         
	                <i class="am-icon-check"></i></li>                                 
	                <li class="" data-index="2" data-group="0" data-value="2">         
	                <span class="am-selected-text">积分降序</span>         
	                <i class="am-icon-check"></i></li>                                 
	                <li class="" data-index="3" data-group="0" data-value="3">         
	                <span class="am-selected-text">人气</span>         
	                <i class="am-icon-check"></i></li>            
                </ul>    
                <div class="am-selected-hint"></div>  </div></div>-->
                <span class="icon_activity am-fr"></span>
            </ul>
            
            <div class="am-tabs-bd" style="background:#f3f3f3;">
                <div id="tab1">
                <notempty name="item_list">
                    <ul class="am-avg-sm-2 am-avg-md-4 am-avg-lg-4" id="new_change">
                    <volist name="item_list" id="vo">
                    <li class="am-articles fq-background-white">
                        <div>
                              <a href="{:U('Gift/detail',array('id'=>$vo['id']))}">
                                  <img src="{:attach(str_replace('_s.'.array_pop(explode('.', $vo['img'])), '_b.'.array_pop(explode('.', $vo['img'])), $vo['img']), 'score_item')}" class="thumbnail am-img-responsive">
                                  </a>
                                   <div class="am-padding-horizontal-xs">
                                       <span><strong class="line-clamp am-margin-bottom-xs">{$vo.title}</strong></span>
                                        <span class="credit am-fl">积分：<span class="am-credit">{$vo.score}</span></span>
                                         <br>
                                         <span class="price am-fl">市场价：¥<span class="am-price">{$vo.price}</span></span>
                                        <br>
                                        <div class="am-num ">
                                            <span><span class="am-convert">{$vo.buy_num}</span>人兑换</span>
                                            <span class="am-fr"><span class="am-stick">{$vo.stock}</span>库存</span> 
                                             <br>
                                   </div>
                                          <span class="am-text-xs am-fl am-num">截止时间：{$vo.end_time|date="Y-m-d",###}</span>                                
                                  <div class="am-center am-text-center" style="clear:both">
                                            <a type="button" href="{:U('Gift/detail',array('id'=>$vo['id']))}" class="am-direct am-radius am-padding-horizontal-sm am-padding-vertical-xs am-margin-vertical-xs">立即兑换</a>
                                   </div>
                               </div>
                         </div>
			        </li>
                    </volist>
                    </ul>
                 <else/>   
                    <div class="zone am-margin-top am-text-center" style="display: block; width: 100%;">尚未发布奖品内容</div>
                 </notempty>
                   <!-- <ul class="am-pagination am-pagination-centered am-text-xs " id="page" style="margin: 1rem 0 0.6rem 0;"></ul>-->
                </div>
            </div>
            
        </div>
    </nav>
</div>
<include file="public/foot" />
<style>
    .am-message {
        height: 48px;
    }
    .am-exchange
    {
        border: .1rem solid #f3e7e3;
        margin-top: .8rem;
    }
    .am-articles {
        border:.1rem solid #f3f3f3;
    } 
    .am-btn-default {
        border: 0;
    }
    .am-btn span,
    .am-btn i {
        padding-top: .1rem;
    }
    .am-selected {
        float: right;
        border-left: .1rem solid #f3e7e3;
    }
   .am-dropdown.am-active .am-btn-default.am-dropdown-toggle {
        background: 0;
    }
    .am-selected-list {
        font-size: 1.4rem;
    }
    .am-selected-list li.am-checked .am-icon-check,
    .am-checked,
    i,
    .am-display .am-vertical-align .am-selected-status,
    .am-current,
    .am-icon-plus-circle{
	  color: #f54d23;
    }
    .am-pagination > .am-active > a{
        background-color: #f54d23;
        border-color: #f54d23;
    }
</style>
<div class="am-hide"></div>
<script>
    //处理时间戳
    function get_time(time) {
        var timeDate = new Date(time * 1000);
        var year = timeDate.getFullYear();
        var month = timeDate.getMonth() + 1;
        var day = timeDate.getDate();
        var hour = timeDate.getHours();
        var minute = timeDate.getMinutes();
        var second = timeDate.getSeconds();
        if (month < 10)
            month = '0' + month;
        if (day < 10)
            day = '0' + day;
        if (hour < 10)
            hour = '0' + hour;
        if (minute < 10)
            minute = '0' + minute;
        if (second < 10)
            second = '0' + second;
        var date = year + '.' + month + '.' + day;
        return date;
    }
    $(function () {
        function checksearch(checksort, type) {
            $.ajax({
                type: 'get',
                dataType: 'json',
                url: '{:U('Gift/index')}',
                data: { "sort": checksort, "cid": type },
                success: function (data) {
                    $('.icon_activity').html('');
                    var len = data.data.length;
                    var obj= data.data;
                    if (len > 0) {
                        var html = '';
                        for (var i = 0; i < len; i++) {
                            if (obj[i]['end_time'] != 0) {
                                activity_time = get_time(obj[i]['end_time']);
                            } else {
                                activity_time = '暂未设置';
                            }
							if(obj[i]['virtual_exchanged']>0){
								exchanged=parseInt(obj[i]['exchanged'])+parseInt(obj[i]['virtual_exchanged']);
							}else{
								exchanged=obj[i]['exchanged'];
							}
                             html += '<li  class="am-articles fq-background-white" ><div><a  href="' + obj[i]['url'] + '"><img src="' + obj[i]['img'] + '" class="thumbnail am-img-responsive"/></a><div class="am-padding-horizontal-xs"><span><strong class="line-clamp am-margin-bottom-xs">' + obj[i]['title'] + '</strong></span><span class="credit am-fl">积分：<span class="am-credit">' + obj[i]['score'] + '</span></span><br /><span class="price am-fl">市场价：￥<span class="am-price">' + obj[i]['price'] + '</span></span><br /><div class="am-num "><span><span class="am-convert">' +obj[i]['buy_num'] + '</span>人兑换</span><span class="am-fr"><span class="am-stick">' + obj[i]['stock'] + '</span>库存</span><br /></div><span class="am-text-xs am-fl am-num">截止时间：' + activity_time + '</span><div class="am-center am-text-center" style="clear:both"><a type="button" href="' + obj[i]['url'] + '" class="am-direct am-radius am-padding-horizontal-sm am-padding-vertical-xs am-margin-vertical-xs">立即兑换</a></div></div></div></li>'
                        }
                        $('#new_change').html(html);
                        $('.zone').hide();
                    } else {
                        $('#new_change').html('');
                        $('.zone').show();
                    }
                }
            });
        }
        //排序
        $('.sort').change(function () {
            var backup = $(this).attr('data-selected');
            var checksort = $(this).val();
          //  var type = $(this).attr('data-type');
            var type = '{$cid}';
            if (backup == checksort) {
                return false;
            }
            $(this).attr('data-selected', checksort);
            $('.icon_activity').html('<i class="am-icon-spinner am-icon-pulse am-margin-top-xs am-margin-right-xs"></i>');
            checksearch(checksort, type);
        });

        //公告展示
        $('.notice_alert').click(function () {
            var notice_content = $('.get_notice').html();
            $('#fq_alert_title').text('商城公告');
            $("#fq_alert_info").html('<div class="am-text-left" style="color:#C98080">' + notice_content + '</div>');
            $('#fq_alert').modal();

        });
});
</script>
</body>
</html>